<?php

/*
 * This file is part of ibrand/EC-Open-Server.
 *
 * (c) iBrand <https://www.ibrand.cc>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */


$router->post('oauth/MiniProgramLogin', 'MiniProgramLoginController@login')->name('api.oauth.miniprogram.login');
$router->post('oauth/MiniProgramMobileLogin', 'MiniProgramLoginController@mobileLogin')->name('api.oauth.miniprogram.mobile.login');


$router->post('wechat/wechattest', 'MiniProgramLoginController@wechattest')->name('api.oauth.miniprogram.wechat.test');


$router->post('store/list', 'GoodsController@indexs')->name('api.goods.list');
$router->get('store/detail/{id}', 'GoodsController@show')->name('api.goods.detail');
$router->post('goods/detail', 'GoodsController@goodsDetail')->name('api.goods.details');
$router->post('goods/getcomments', 'GoodsController@getComments')->name('api.goods.getcomments');
$router->get('store/detail/{id}/stock', 'GoodsController@getStock')->name('api.goods.detail.stock');
$router->get('store/detail/{id}/share/img', 'GoodsController@shareImg')->name('api.goods.detail.share.img');
$router->any('weixin/index', 'WeixinController@index');
$router->get('home', 'HomeController@index')->name('api.home.index');
$router->get('accesstoken', 'HomeController@accesstoken')->name('api.home.accesstoken');
$router->get('test', 'HomeController@test')->name('api.home.test');
$router->get('category', 'HomeController@category')->name('api.home.category');

$router->post('recommend/index', 'HomeController@reindex')->name('api.recommend.index');
$router->post('shop/index', 'HomeController@shopIndex')->name('api.shop.index');
$router->post('file/upload', 'UserController@upload')->name('api.file.upload');


$router->post('card/cardsign', 'UserController@cardsign')->name('api.cardsign');

$router->any('wechat/notify', 'WechatPayNotifyController@notify');

$router->post('shoppingCart/discount', 'DiscountController@shoppingCartDiscount')->name('api.shopping.cart.discount');

$router->group(config('ibrand.ec-open-api.routeAuthAttributes'), function ($router) {

    /************************* 购物车 **********************/

    $router->post('cart/addcart', 'ShoppingCartController@addCart')->name('api.cart.addcart');
    $router->post('cart/getcart', 'ShoppingCartController@getCart')->name('api.cart.getcart');
    $router->post('cart/delcart', 'ShoppingCartController@delCart')->name('api.cart.delcart');
    $router->post('cart/editcart', 'ShoppingCartController@editCart')->name('api.cart.editcart');
    $router->post('order/addorder', 'ShoppingController@addOrder')->name('api.cart.addorder');



    $router->post('shopping/cart', 'ShoppingCartController@store')->name('api.shopping.cart.store');
    $router->post('goods/newcomergoodslist', 'GoodsController@newComerGoodsLists')->name('api.goods.newcomergoodslists');

    $router->get('shopping/cart', 'ShoppingCartController@index')->name('api.shopping.cart');
    $router->put('shopping/cart/{id}', 'ShoppingCartController@update')->name('api.shopping.cart.put');
    $router->delete('shopping/cart/{id}', 'ShoppingCartController@delete')->name('api.shopping.cart.delete');
    $router->post('shopping/cart/clear', 'ShoppingCartController@clear')->name('api.shopping.cart.clear');
    $router->get('shopping/cart/count', 'ShoppingCartController@count')->name('api.shopping.cart.count');

    /************************* 购物流程 **********************/
    $router->post('shopping/order/checkout', 'ShoppingController@checkout')->name('api.shopping.order.checkout');
    $router->post('shopping/order/confirm', 'ShoppingController@confirm')->name('api.shopping.order.confirm');
    $router->post('order/charge', 'WechatPayController@createCharge')->name('api.shopping.order.charge');
    $router->post('order/refund', 'WechatPayController@refund')->name('api.shopping.order.refund');
    $router->post('order/transformer', 'WechatPayController@transformer')->name('api.shopping.order.transformer');
    $router->post('shopping/order/paid', 'PaymentController@paidSuccess')->name('api.shopping.order.paid');
    $router->post('shopping/order/cancel', 'ShoppingController@cancel')->name('api.shopping.order.cancel');
    $router->post('shopping/order/received', 'ShoppingController@received')->name('api.shopping.order.received');
    $router->post('shopping/order/delete', 'ShoppingController@delete')->name('api.shopping.order.delete');
    $router->post('order/review', 'ShoppingController@review')->name('api.shopping.order.review');
    $router->post('order/reviews', 'ShoppingController@reviews')->name('api.shopping.order.reviews');
    $router->post('shopping/order/delivery', 'ShoppingController@delivery')->name('api.order.delivery');

    /************************* 收货地址 **********************/
    $router->get('address', 'AddressController@index')->name('api.address.list');
    $router->post('address', 'AddressController@store')->name('api.address.store');
    $router->post('address/update', 'AddressController@update')->name('api.address.update');
    $router->get('address/{id}', 'AddressController@show')->where('id', '[0-9]+')->name('api.address.show');
    $router->delete('address/{id}', 'AddressController@delete')->name('api.address.delete');
    $router->post('address/default', 'AddressController@default')->name('api.address.default');


    /*************************** 地址 ********************/
    $router->post('user/editreceiv', 'AddressController@editreceiv')->name('api.user.editreceiv');          #地址修改
    $router->post('user/addreceiv', 'AddressController@addreceiv')->name('api.user.addreceiv');          #地址添加
    $router->post('user/listreceiv', 'AddressController@index')->name('api.user.listreceiv');          #地址列表


    /*************************** 我的收藏 ********************/
    $router->get('favorite', 'FavoriteController@index')->name('api.favorite');
    $router->post('favorite', 'FavoriteController@store')->name('api.favorite.store');
    $router->delete('favorite', 'FavoriteController@delete')->name('api.favorite.delete');
    $router->post('favorite/delFavs', 'FavoriteController@delFavs')->name('api.favorite.delFavs');
    $router->get('favorite/isfav', 'FavoriteController@getIsFav')->name('api.favorite.isFav');

    /************************* 用户 **********************/
    $router->get('me', 'UserController@me')->name('api.me');
    $router->post('member/member', 'UserController@getMember')->name('api.member');
    $router->post('member/addmember', 'UserController@addMember')->name('api.addmember');

    $router->post('member/addsigns', 'UserController@addSigns')->name('api.addSigns');
    $router->post('member/getsigns', 'UserController@getsigns')->name('api.getsigns');


    $router->post('user/register', 'UserController@register')->name('api.register');
    $router->post('user/getbehavior', 'UserController@getBehavior')->name('api.getbehavior');




    $router->post('card/cardsign', 'UserController@cardsign')->name('api.cardsign');

    $router->post('user/goodgirl', 'UserController@goodGirl')->name('api.goodGirl');
    $router->post('user/gettryeating', 'UserController@getTryEating')->name('api.getTryEating');
    $router->post('user/saveformid', 'UserController@saveformid')->name('api.saveformid');;             #收集用户formid
    $router->post('user/sendTemplate', 'UserController@sendTemplate')->name('api.sendTemplate');;             #收集用户formid



    $router->post('card/getUserCards', 'UserController@getUserCards')->name('api.getUserCards');
    $router->get('users/ucenter', 'UserController@ucenter')->name('api.user.ucenter');
    $router->post('users/update/info', 'UserController@updateInfo')->name('api.user.update.info');
    $router->post('users/update/mobile', 'UserController@updateMobile')->name('api.user.update.mobile');
    $router->post('users/upload/avatar', 'UserController@uploadAvatar')->name('api.user.upload.avatar');
    $router->post('order/list', 'OrderController@getOrders')->name('api.order.list');
    $router->post('order/orderlist', 'OrderController@orderList')->name('api.order.orderList');
    $router->post('order/editorder', 'OrderController@editOrder')->name('api.order.editOrder');
    $router->post('order/editOrders', 'OrderController@editOrders')->name('api.order.editOrders');
    $router->get('order/{order_no}', 'OrderController@getOrderDetails')->name('api.order');
    $router->post('order/apply', 'OrderController@apply')->name('api.shopping.order.apply');

    $router->post('couponlist', 'CouponController@index')->name('api.coupon.couponlist');
    $router->post('couponreceive', 'CouponController@receive')->name('api.coupon.receive');
    $router->post('coupon/receive', 'CouponController@receiveCounpon')->name('api.coupon.receivecounpon');
    $router->post('couponcheck', 'CouponController@check')->name('api.coupon.check');
    $router->post('coupon/getgoodscoupon', 'CouponController@getGoodsCoupon')->name('api.coupon.getgoodscoupon');
    $router->get('coupon/{id}', 'CouponController@show')->name('api.coupon.show');

    /************************* 促销活动和优惠券 **********************/
    $router->post('discount', 'DiscountController@create')->name('api.discount.create');
    $router->post('coupon', 'CouponController@create')->name('api.coupon.create');
    $router->post('coupon/take', 'CouponController@take')->name('api.coupon.take');

    /************************* 拼团 **********************/
    $router->post('activity/aclist', 'ActivityController@acList')->name('api.activity.acList');
    $router->post('activity/acdetail', 'ActivityController@acDetail')->name('api.activity.acDetail');
    $router->post('activity/getteamid', 'ActivityController@getTeamId')->name('api.activity.getTeamId');
    $router->post('activity/makeqrcode', 'ActivityController@makeqrcode')->name('api.activity.makeqrcode');


    $router->any('supplygoods', 'WeixinController@supplygoods');
    $router->any('createmenu', 'WeixinController@createMenu');
    $router->any('getmenu', 'WeixinController@getMenu');
    $router->any('tomessage', 'WeixinController@toMessage');
    $router->any('test', 'WeixinController@test');
    $router->any('createqrcode', 'WeixinController@createqrcode'); //创建永久二维码ticket
});
